//
//  String+Extension.swift
//  TinyShopKeeper
//
//  Created by huangtao on 16/5/30.
//  Copyright © 2016年 fish. All rights reserved.
//

import Foundation

extension String
{
    func md5String() -> String{
        let cStr = (self as NSString).UTF8String
        let buffer = UnsafeMutablePointer<UInt8>.alloc(16)
        CC_MD5(cStr,(CC_LONG)(strlen(cStr)), buffer)
        let md5String = NSMutableString()
        for var i = 0; i < 16; ++i{
            md5String.appendFormat("%02x", buffer[i])
        }
        
        free(buffer)
        return md5String as String
    }

}


